h/*********************************************************************
*                                                                    *
* input  -- provides initial values/parameters for different         *
* evolutions                                                         *
* Parameters:                                                        *
* y_a_ptr        -- pointer where to write the initial data          *
* initial_time   -- initial time                                     *
*                                                                    *
* Returns: pointer to field_array where data was writen              *
*                                                                    *
*********************************************************************/
#include "first_macro_2d.h"  /* Where global parameters are defined */
#include "structs_2d.h"      /* Where structures are defined */
#include "gen_2d.h"



/*-----------------------------------------------------------------------*/
/* Inputs for 2-D PG Wave equation  */

void heat_2d_input(struct GRID_PAR *grid_par, 
	      struct FUNCTION_PAR *function_par, 
	      struct INI_PAR *ini_pars,
	      struct PLOT_PAR *plot_par){

  /* input data structure */

	struct entries entries1;
	
#ifdef FILE_INPUT
	char file_name[30];
	FILE *file_data_ptr; // = (*plot_par).input_data_file_ptr;
#endif


  
  /* Get Web Values */
#ifdef WEB_INPUT

	parse_stain(&entries1);

	if((*grid_par).grid==0){
		printf("Content-Type: text/html%c%c",10,10);
		printf("<body background=\"http://localhost/~reula/Marble.jpg\">%c",10);
		printf("<h1>Programa Wave KS 2D</h1>%c",10);
		printf("version 0.1 <p>%c",10); 

		printf("You submitted the following name/value pairs:<p>%c",10);
		printf("<ul>%c",10);
	}	

#endif 


#ifdef FILE_INPUT

	parse_filedata(&entries1);
	
	strcpy(file_name, get_value_char("file_name",&entries1,plot_par,grid_par));
  /* strcpy((*plot_par).input_file_name, get_value_char("file_name",&entries1,plot_par,grid_par)); */
	strcpy((*plot_par).output_file_name,file_name);
	strcpy((*plot_par).input_file_name,"input_data_");
	strcat((*plot_par).input_file_name, file_name  /* strcat((*plot_par).input_file_name,"input_data_"); */ );
	(*plot_par).input_data_file_ptr = fopen((*plot_par).input_file_name,"w");

	file_data_ptr = (*plot_par).input_data_file_ptr;


  
	if((*grid_par).grid==0){
		fprintf(OUT_PUT,"Content-Type: text/html%c%c",10,10);
		fprintf(OUT_PUT,"<body background=\"http://localhost/~reula/Marble.jpg\">%c",10);
		fprintf(OUT_PUT,"<h1>Programa Wave KS_2D</h1></br>%c",10);
		fprintf(OUT_PUT,"version 0.1 <p>%c",10); 
		printf("Programa Heat S2\n");
		printf("version 0.1\n"); 

		fprintf(OUT_PUT,"You submitted the following name/value pairs:<p>%c",10);
		fprintf(OUT_PUT,"<ul>%c",10);

		printf("You submitted the following name/value pairs:\n");
		printf("\n");
	}
#endif



  /* grid  values */
  
    get_grid_data_2d(&entries1,plot_par,grid_par);


	(*grid_par).n_fields =  N_FIELDS;
  
// plot data 


	get_plot_data_2d(&entries1,plot_par,grid_par);

	(*plot_par).grid_plot_pts_1 = ((*grid_par).n_gridpts_1 - 1)/(*plot_par).factor_1 + 1;
	(*plot_par).grid_plot_pts_2 = ((*grid_par).n_gridpts_2 - 1)/(*plot_par).factor_2 + 1;
	(*plot_par).n_gridpts_plot = (*plot_par).grid_plot_pts_1 * (*plot_par).grid_plot_pts_2;


  /* Function parameters */

	(*function_par).grid_ptr = grid_par;


	(*function_par).mm  = get_value_double_print("mm",&entries1,plot_par,grid_par);
	(*function_par).sigma  = get_value_double_print("sigma",&entries1,plot_par,grid_par);
	(*function_par).delta  = get_value_double_print("delta",&entries1,plot_par,grid_par);


  /* initial data parameters (used in inidat.c and to compare solutions)*/
      
	(*ini_pars).function_par_ptr = function_par;
	(*ini_pars).grid_ptr = grid_par;

	(*ini_pars).a0  = get_value_double_print("a0",&entries1,plot_par,grid_par);
	(*ini_pars).k_a_10  = get_value_double_print("k_a_10",&entries1,plot_par,grid_par);
	(*ini_pars).k_a_20  = get_value_double_print("k_a_20",&entries1,plot_par,grid_par);
	(*ini_pars).shift_a0  = get_value_double_print("shift_a0",&entries1,plot_par,grid_par);

	(*ini_pars).a1  = get_value_double_print("a1",&entries1,plot_par,grid_par);
	(*ini_pars).k_a_11  = get_value_double_print("k_a_11",&entries1,plot_par,grid_par);
	(*ini_pars).k_a_21  = get_value_double_print("k_a_21",&entries1,plot_par,grid_par);
	(*ini_pars).shift_a1  = get_value_double_print("shift_a1",&entries1,plot_par,grid_par);

	(*ini_pars).c0  = get_value_double_print("c0",&entries1,plot_par,grid_par);
	(*ini_pars).k_c_10  = get_value_double_print("k_c_10",&entries1,plot_par,grid_par);
	(*ini_pars).k_c_20  = get_value_double_print("k_c_20",&entries1,plot_par,grid_par);
	(*ini_pars).shift_c0  = get_value_double_print("shift_c0",&entries1,plot_par,grid_par);

	(*ini_pars).c1  = get_value_double_print("c1",&entries1,plot_par,grid_par);
	(*ini_pars).k_c_11  = get_value_double_print("k_c_11",&entries1,plot_par,grid_par);
	(*ini_pars).k_c_21  = get_value_double_print("k_c_21",&entries1,plot_par,grid_par);
	(*ini_pars).shift_c1  = get_value_double_print("shift_c1",&entries1,plot_par,grid_par);

	(*ini_pars).b0  = get_value_double_print("b0",&entries1,plot_par,grid_par);
	(*ini_pars).sigma_b0  = get_value_double_print("sigma_b0",&entries1,plot_par,grid_par);
	(*ini_pars).c0_1  = get_value_double_print("c0_1",&entries1,plot_par,grid_par);
	(*ini_pars).c0_2  = get_value_double_print("c0_2",&entries1,plot_par,grid_par);

	(*ini_pars).b1  = get_value_double_print("b1",&entries1,plot_par,grid_par);
	(*ini_pars).sigma_b1  = get_value_double_print("sigma_b1",&entries1,plot_par,grid_par);
	(*ini_pars).c1_1  = get_value_double_print("c1_1",&entries1,plot_par,grid_par);
	(*ini_pars).c1_2  = get_value_double_print("c1_2",&entries1,plot_par,grid_par);

	(*ini_pars).v1  = get_value_double_print("v1",&entries1,plot_par,grid_par);
	(*ini_pars).v2  = get_value_double_print("v2",&entries1,plot_par,grid_par);
 
	(*ini_pars).initial_data_type  = get_value_int_print("initial_data_type",&entries1,plot_par,grid_par);;
 


}








/****************************************************************************
 * Get values from an entry array and asign them to pointer given           *
 *                                                                          *
 * m -- pointer to int giving the number of entries                         * 
 * name[10] -- name of variable as given in entry                           *
 * entries  -- pointer to entry from where to obtain the pairs name/value   *
 * Return   -- value asigned (in double) to name                            *
 ***************************************************************************/



double get_value_double_print(char name[MAX_ENTRY], 
			struct entries *entries2,
			struct PLOT_PAR *plot_par,
			struct GRID_PAR *grid_par
			) {
     double interm_float;
     char entry_name[MAX_ENTRY];
     char entry_val[MAX_ENTRY];
     int j;
     int max = (*entries2).dim+1;
     FILE *file_data_ptr = (*plot_par).input_data_file_ptr;


  for(j=0;j<max;++j){
    strcpy(entry_name,(*entries2).entry[j].name);
    strcpy(entry_val,(*entries2).entry[j].val);
    if(strcmp(name,entry_name) == 0) {
      sscanf(entry_val, "%lf", &interm_float);
	  if((*grid_par).grid==0){
		fprintf(OUT_PUT,"<li> <code>%s = %f</code>%c",entry_name,(double)interm_float,10);
			#ifdef FILE_INPUT
				printf("%s = %f\n",entry_name,(double)interm_float);
			#endif
		}
      goto L1;
    }
  }
  fprintf(OUT_PUT,"name %s has no counterpart in the entry given", name);
  exit(0);
 L1: return((double)interm_float);
}


double get_value_double(char name[MAX_ENTRY], 
			struct entries *entries2,
			struct PLOT_PAR *plot_par,
			struct GRID_PAR *grid_par
			) {
     double interm_float;
     char entry_name[MAX_ENTRY];
     char entry_val[MAX_ENTRY];
     int j;
     int max = (*entries2).dim+1;
     FILE *file_data_ptr = (*plot_par).input_data_file_ptr;


  for(j=0;j<max;++j){
    strcpy(entry_name,(*entries2).entry[j].name);
    strcpy(entry_val,(*entries2).entry[j].val);
    if(strcmp(name,entry_name) == 0) {
      sscanf(entry_val, "%lf", &interm_float);
//      fprintf(OUT_PUT,"<li> <code>%s = %f</code>%c",entry_name,(double)interm_float,10);
//#ifdef FILE_INPUT
//printf("%s = %f\n",entry_name,(double)interm_float);
//#endif
      goto L1;
    }
  }
  fprintf(OUT_PUT,"name %s has no counterpart in the entry given", name);
  exit(0);
 L1: return((double)interm_float);
}

// ---------------------------------------------------------------------------------------------------------

int get_value_int_print(char name[MAX_ENTRY], 
		  struct entries *entries2,
		  struct PLOT_PAR *plot_par,
			struct GRID_PAR *grid_par
		  ) {
     int interm_int;
     char entry_name[MAX_ENTRY];
     char entry_val[MAX_ENTRY];
     int j;
     int max = (*entries2).dim+1;
     FILE *file_data_ptr = (*plot_par).input_data_file_ptr;

  for(j=0;j<max;++j){
    strcpy(entry_name,(*entries2).entry[j].name);
    strcpy(entry_val,(*entries2).entry[j].val);
    if(strcmp(name,entry_name) == 0) {
      sscanf(entry_val, "%d", &interm_int);
	  if((*grid_par).grid==0){
		fprintf(OUT_PUT,"<li> <code>%s = %d</code>%c",entry_name,(int)interm_int,10);
			#ifdef FILE_INPUT
			printf("%s = %d\n",entry_name,(int)interm_int);
			#endif
		}
      goto L1;
    }
  }
  fprintf(OUT_PUT,"name %s has no counterpart in the entry given", name);
  exit(0);
 L1: return((int)interm_int);
}

// ---------------------------------------------------------------------------------------------------------

int get_value_int(char name[MAX_ENTRY], 
		  struct entries *entries2,
		  struct PLOT_PAR *plot_par,
		  struct GRID_PAR *grid_par
		  ) {
     int interm_int;
     char entry_name[MAX_ENTRY];
     char entry_val[MAX_ENTRY];
     int j;
     int max = (*entries2).dim+1;
     FILE *file_data_ptr = (*plot_par).input_data_file_ptr;

  for(j=0;j<max;++j){
    strcpy(entry_name,(*entries2).entry[j].name);
    strcpy(entry_val,(*entries2).entry[j].val);
    if(strcmp(name,entry_name) == 0) {
      sscanf(entry_val, "%d", &interm_int);
//      fprintf(OUT_PUT,"<li> <code>%s = %d</code>%c",entry_name,(int)interm_int,10);
//#ifdef FILE_INPUT
//printf("%s = %d\n",entry_name,(int)interm_int);
//#endif
      goto L1;
    }
  }
  fprintf(OUT_PUT,"name %s has no counterpart in the entry given", name);
  exit(0);
 L1: return((int)interm_int);
}

// ---------------------------------------------------------------------------------------------------------

char *get_value_char_print(char name[MAX_ENTRY], 
		     struct entries *entries2,
		     struct PLOT_PAR *plot_par,
			 struct GRID_PAR *grid_par
		     ) {
       int j;
       int max = (*entries2).dim+1; 
       FILE *file_data_ptr = (*plot_par).input_data_file_ptr;

       for(j=0;j<max;++j){
	 if(strcmp(name,(*entries2).entry[j].name) == 0) {
		 if((*grid_par).grid==0){
			#ifdef WEB_INPUT
				printf("<li> <code>%s = %s</code>%c",(*entries2).entry[j].name,(*entries2).entry[j].val,10);
			#endif
			#ifdef FILE_INPUT
				printf("%s = %s\n",(*entries2).entry[j].name,(*entries2).entry[j].val);
			#endif
		}
      goto L1;
    }
  }
  fprintf(OUT_PUT,"name %s has no counterpart in the entry given", name);
  exit(0);
 L1: return((*entries2).entry[j].val);
}

// ---------------------------------------------------------------------------------------------------------

char *get_value_char(char name[MAX_ENTRY], 
		     struct entries *entries2,
		     struct PLOT_PAR *plot_par,
			struct GRID_PAR *grid_par
		     ) {
       int j;
       int max = (*entries2).dim+1; 
       FILE *file_data_ptr = (*plot_par).input_data_file_ptr;

       for(j=0;j<max;++j){
	 if(strcmp(name,(*entries2).entry[j].name) == 0) {
//#ifdef WEB_INPUT
//	   printf("<li> <code>%s = %s</code>%c",(*entries2).entry[j].name,(*entries2).entry[j].val,10);
//#endif
//#ifdef FILE_INPUT
//printf("%s = %s\n",(*entries2).entry[j].name,(*entries2).entry[j].val);
//#endif
      goto L1;
    }
  }
  fprintf(OUT_PUT,"name %s has no counterpart in the entry given", name);
  exit(0);
 L1: return((*entries2).entry[j].val);
}

// ---------------------------------------------------------------------------------------------------------

void parse_stain(struct entries *entriesp){
    int m=0;
    register int x;
    int cl;
    cl = atoi(getenv("CONTENT_LENGTH"));
    if (cl > ((MAX_ENTRIES+1) * MAX_ENTRY)+10){
	printf("data names too big or too many of them");
	exit(0);
    }
    for(x=0;cl && (!feof(stdin));x++) {
        m=x;
        (*entriesp).entry[x].val = fmakeword(stdin,'&',&cl);
        plustospace((*entriesp).entry[x].val);
        unescape_url((*entriesp).entry[x].val);
        (*entriesp).entry[x].name = makeword((*entriesp).entry[x].val,'=');
    }
    (*entriesp).dim = m;
  }


/*******************************************************************************
 * This function parses a file called data                                     *
 * Comments on that file uses a # at the begining of the file                  *
 * it asign lines of the form name = value                                     *
 * to entries in the structure entries                                         *
 ******************************************************************************/

void parse_filedata(struct entries *entriesp){
    FILE *fdata_ptr;
    FILE *fdata_ptr_dummy;

    int m=0;
    int x;
    int incx=0;
    int cl=0;

    fdata_ptr = fopen("data","r");
    fdata_ptr_dummy = fopen("data","r");

    while(getc(fdata_ptr_dummy) != EOF)
	cl++;
    x=0;
    while(cl && (!feof(fdata_ptr))){
    
        m=x;
        (*entriesp).entry[x].val = fmakeword(fdata_ptr,'\n',&cl);
	incx=((*entriesp).entry[x].val[0]!='#');

	if(incx){
        (*entriesp).entry[x].name = makeword((*entriesp).entry[x].val,'=');

	}
	x=x+incx;
    }
    (*entriesp).dim = m;
    fclose(fdata_ptr);
    fclose(fdata_ptr_dummy);
}





// ---------------------------------------------------------------------------------------------------










void   get_grid_data_2d(struct entries *entries1, 
						struct PLOT_PAR *plot_par, 
						struct GRID_PAR *grid_par){

  (*grid_par).initial_time = get_value_double_print("initial_time",entries1,plot_par,grid_par);
  (*grid_par).final_time = get_value_double_print("final_time",entries1,plot_par,grid_par);
  (*grid_par).data_steps = get_value_int_print("data_steps",entries1,plot_par,grid_par);
  (*grid_par).int_steps = get_value_int_print("int_steps",entries1,plot_par,grid_par);

  (*grid_par).start_grid_1 = get_value_int_print("start_grid_1",entries1,plot_par,grid_par);
  (*grid_par).final_grid_1 = get_value_int_print("final_grid_1",entries1,plot_par,grid_par);
  (*grid_par).start_grid_2 = get_value_int_print("start_grid_2",entries1,plot_par,grid_par);
  (*grid_par).final_grid_2 = get_value_int_print("final_grid_2",entries1,plot_par,grid_par);
  
  (*grid_par).n_gridpts_1 = (*grid_par).final_grid_1 - (*grid_par).start_grid_1;
  (*grid_par).n_gridpts_2 = (*grid_par).final_grid_2 - (*grid_par).start_grid_2;
  (*grid_par).n_grid_pts = (*grid_par).n_gridpts_1*(*grid_par).n_gridpts_2;
#ifdef DEBUG
  printf("Number of gridpoints 1 = %d at imput function \n",(*grid_par).n_gridpts_1);
  printf("Number of gridpoints 2 = %d at imput function \n",(*grid_par).n_gridpts_2);
  printf("Number of gridpoints = %d at imput function \n",(*grid_par).n_grid_pts);
#endif



#ifdef EXCISION
  (*grid_par).exc_grid_1 = get_value_int_print("exc_grid_1",entries1,plot_par,grid_par);
  (*grid_par).exc_grid_2 = get_value_int_print("exc_grid_2",entries1,plot_par,grid_par);
#endif


  (*grid_par).initial_x = get_value_double_print("initial_x",entries1,plot_par,grid_par);
  (*grid_par).final_x = get_value_double_print("final_x",entries1,plot_par,grid_par);
  (*grid_par).initial_y = get_value_double_print("initial_y",entries1,plot_par,grid_par);
  (*grid_par).final_y = get_value_double_print("final_y",entries1,plot_par,grid_par);

if((*grid_par).grid==0){
	#ifdef WEB_INPUT
		printf("<li> <code> grd.n_gridpts_1 = %d</code>%c",(*grid_par).n_gridpts_1,10);
		printf("<li> <code> grd.n_gridpts_2 = %d</code>%c",(*grid_par).n_gridpts_2,10);
    #endif
	#ifdef FILE_INPUT
		printf("grd.n_gridpts_1 = %d\n",(*grid_par).n_gridpts_1);
		printf("grd.n_gridpts_2 = %d\n",(*grid_par).n_gridpts_2);
    #endif

}


  /* grid first side second the value -1 is used to imply outgoing direction */

 (*grid_par).gcs_send[0][0][0].g = get_value_int("gcs_send[0][0][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[0][0][1].g = get_value_int("gcs_send[0][0][1].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[0][1][0].g = get_value_int("gcs_send[0][1][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[0][1][1].g = get_value_int("gcs_send[0][1][1].g",entries1,plot_par,grid_par);

 (*grid_par).gcs_send[1][0][0].g = get_value_int("gcs_send[1][0][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[1][0][1].g = get_value_int("gcs_send[1][0][1].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[1][1][0].g = get_value_int("gcs_send[1][1][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[1][1][1].g = get_value_int("gcs_send[1][1][1].g",entries1,plot_par,grid_par);

 (*grid_par).gcs_send[2][0][0].g = get_value_int("gcs_send[2][0][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[2][0][1].g = get_value_int("gcs_send[2][0][1].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[2][1][0].g = get_value_int("gcs_send[2][1][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[2][1][1].g = get_value_int("gcs_send[2][1][1].g",entries1,plot_par,grid_par);

 (*grid_par).gcs_send[3][0][0].g = get_value_int("gcs_send[3][0][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[3][0][1].g = get_value_int("gcs_send[3][0][1].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[3][1][0].g = get_value_int("gcs_send[3][1][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[3][1][1].g = get_value_int("gcs_send[3][1][1].g",entries1,plot_par,grid_par);

 (*grid_par).gcs_send[4][0][0].g = get_value_int("gcs_send[4][0][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[4][0][1].g = get_value_int("gcs_send[4][0][1].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[4][1][0].g = get_value_int("gcs_send[4][1][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[4][1][1].g = get_value_int("gcs_send[4][1][1].g",entries1,plot_par,grid_par);

 (*grid_par).gcs_send[5][0][0].g = get_value_int("gcs_send[5][0][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[5][0][1].g = get_value_int("gcs_send[5][0][1].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[5][1][0].g = get_value_int("gcs_send[5][1][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[5][1][1].g = get_value_int("gcs_send[5][1][1].g",entries1,plot_par,grid_par);

 (*grid_par).gcs_send[0][0][0].c = get_value_int("gcs_send[0][0][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[0][0][1].c = get_value_int("gcs_send[0][0][1].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[0][1][0].c = get_value_int("gcs_send[0][1][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[0][1][1].c = get_value_int("gcs_send[0][1][1].c",entries1,plot_par,grid_par);

 (*grid_par).gcs_send[1][0][0].c = get_value_int("gcs_send[1][0][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[1][0][1].c = get_value_int("gcs_send[1][0][1].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[1][1][0].c = get_value_int("gcs_send[1][1][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[1][1][1].c = get_value_int("gcs_send[1][1][1].c",entries1,plot_par,grid_par);

 (*grid_par).gcs_send[2][0][0].c = get_value_int("gcs_send[2][0][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[2][0][1].c = get_value_int("gcs_send[2][0][1].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[2][1][0].c = get_value_int("gcs_send[2][1][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[2][1][1].c = get_value_int("gcs_send[2][1][1].c",entries1,plot_par,grid_par);

 (*grid_par).gcs_send[3][0][0].c = get_value_int("gcs_send[3][0][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[3][0][1].c = get_value_int("gcs_send[3][0][1].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[3][1][0].c = get_value_int("gcs_send[3][1][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[3][1][1].c = get_value_int("gcs_send[3][1][1].c",entries1,plot_par,grid_par);

 (*grid_par).gcs_send[4][0][0].c = get_value_int("gcs_send[4][0][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[4][0][1].c = get_value_int("gcs_send[4][0][1].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[4][1][0].c = get_value_int("gcs_send[4][1][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[4][1][1].c = get_value_int("gcs_send[4][1][1].c",entries1,plot_par,grid_par);

 (*grid_par).gcs_send[5][0][0].c = get_value_int("gcs_send[5][0][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[5][0][1].c = get_value_int("gcs_send[5][0][1].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[5][1][0].c = get_value_int("gcs_send[5][1][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[5][1][1].c = get_value_int("gcs_send[5][1][1].c",entries1,plot_par,grid_par);

 (*grid_par).gcs_send[0][0][0].s = get_value_int("gcs_send[0][0][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[0][0][1].s = get_value_int("gcs_send[0][0][1].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[0][1][0].s = get_value_int("gcs_send[0][1][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[0][1][1].s = get_value_int("gcs_send[0][1][1].s",entries1,plot_par,grid_par);

 (*grid_par).gcs_send[1][0][0].s = get_value_int("gcs_send[1][0][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[1][0][1].s = get_value_int("gcs_send[1][0][1].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[1][1][0].s = get_value_int("gcs_send[1][1][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[1][1][1].s = get_value_int("gcs_send[1][1][1].s",entries1,plot_par,grid_par);

 (*grid_par).gcs_send[2][0][0].s = get_value_int("gcs_send[2][0][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[2][0][1].s = get_value_int("gcs_send[2][0][1].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[2][1][0].s = get_value_int("gcs_send[2][1][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[2][1][1].s = get_value_int("gcs_send[2][1][1].s",entries1,plot_par,grid_par);

 (*grid_par).gcs_send[3][0][0].s = get_value_int("gcs_send[3][0][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[3][0][1].s = get_value_int("gcs_send[3][0][1].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[3][1][0].s = get_value_int("gcs_send[3][1][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[3][1][1].s = get_value_int("gcs_send[3][1][1].s",entries1,plot_par,grid_par);

 (*grid_par).gcs_send[4][0][0].s = get_value_int("gcs_send[4][0][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[4][0][1].s = get_value_int("gcs_send[4][0][1].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[4][1][0].s = get_value_int("gcs_send[4][1][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[4][1][1].s = get_value_int("gcs_send[4][1][1].s",entries1,plot_par,grid_par);


 (*grid_par).gcs_send[5][0][0].s = get_value_int("gcs_send[5][0][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[5][0][1].s = get_value_int("gcs_send[5][0][1].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[5][1][0].s = get_value_int("gcs_send[5][1][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_send[5][1][1].s = get_value_int("gcs_send[5][1][1].s",entries1,plot_par,grid_par);


 (*grid_par).gcs_recv[0][0][0].g = get_value_int("gcs_recv[0][0][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[0][0][1].g = get_value_int("gcs_recv[0][0][1].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[0][1][0].g = get_value_int("gcs_recv[0][1][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[0][1][1].g = get_value_int("gcs_recv[0][1][1].g",entries1,plot_par,grid_par);

 (*grid_par).gcs_recv[1][0][0].g = get_value_int("gcs_recv[1][0][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[1][0][1].g = get_value_int("gcs_recv[1][0][1].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[1][1][0].g = get_value_int("gcs_recv[1][1][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[1][1][1].g = get_value_int("gcs_recv[1][1][1].g",entries1,plot_par,grid_par);

 (*grid_par).gcs_recv[2][0][0].g = get_value_int("gcs_recv[2][0][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[2][0][1].g = get_value_int("gcs_recv[2][0][1].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[2][1][0].g = get_value_int("gcs_recv[2][1][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[2][1][1].g = get_value_int("gcs_recv[2][1][1].g",entries1,plot_par,grid_par);

 (*grid_par).gcs_recv[3][0][0].g = get_value_int("gcs_recv[3][0][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[3][0][1].g = get_value_int("gcs_recv[3][0][1].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[3][1][0].g = get_value_int("gcs_recv[3][1][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[3][1][1].g = get_value_int("gcs_recv[3][1][1].g",entries1,plot_par,grid_par);

 (*grid_par).gcs_recv[4][0][0].g = get_value_int("gcs_recv[4][0][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[4][0][1].g = get_value_int("gcs_recv[4][0][1].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[4][1][0].g = get_value_int("gcs_recv[4][1][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[4][1][1].g = get_value_int("gcs_recv[4][1][1].g",entries1,plot_par,grid_par);

 (*grid_par).gcs_recv[5][0][0].g = get_value_int("gcs_recv[5][0][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[5][0][1].g = get_value_int("gcs_recv[5][0][1].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[5][1][0].g = get_value_int("gcs_recv[5][1][0].g",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[5][1][1].g = get_value_int("gcs_recv[5][1][1].g",entries1,plot_par,grid_par);

 (*grid_par).gcs_recv[0][0][0].c = get_value_int("gcs_recv[0][0][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[0][0][1].c = get_value_int("gcs_recv[0][0][1].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[0][1][0].c = get_value_int("gcs_recv[0][1][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[0][1][1].c = get_value_int("gcs_recv[0][1][1].c",entries1,plot_par,grid_par);

 (*grid_par).gcs_recv[1][0][0].c = get_value_int("gcs_recv[1][0][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[1][0][1].c = get_value_int("gcs_recv[1][0][1].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[1][1][0].c = get_value_int("gcs_recv[1][1][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[1][1][1].c = get_value_int("gcs_recv[1][1][1].c",entries1,plot_par,grid_par);

 (*grid_par).gcs_recv[2][0][0].c = get_value_int("gcs_recv[2][0][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[2][0][1].c = get_value_int("gcs_recv[2][0][1].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[2][1][0].c = get_value_int("gcs_recv[2][1][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[2][1][1].c = get_value_int("gcs_recv[2][1][1].c",entries1,plot_par,grid_par);

 (*grid_par).gcs_recv[3][0][0].c = get_value_int("gcs_recv[3][0][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[3][0][1].c = get_value_int("gcs_recv[3][0][1].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[3][1][0].c = get_value_int("gcs_recv[3][1][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[3][1][1].c = get_value_int("gcs_recv[3][1][1].c",entries1,plot_par,grid_par);

 (*grid_par).gcs_recv[4][0][0].c = get_value_int("gcs_recv[4][0][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[4][0][1].c = get_value_int("gcs_recv[4][0][1].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[4][1][0].c = get_value_int("gcs_recv[4][1][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[4][1][1].c = get_value_int("gcs_recv[4][1][1].c",entries1,plot_par,grid_par);

 (*grid_par).gcs_recv[5][0][0].c = get_value_int("gcs_recv[5][0][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[5][0][1].c = get_value_int("gcs_recv[5][0][1].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[5][1][0].c = get_value_int("gcs_recv[5][1][0].c",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[5][1][1].c = get_value_int("gcs_recv[5][1][1].c",entries1,plot_par,grid_par);

 (*grid_par).gcs_recv[0][0][0].s = get_value_int("gcs_recv[0][0][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[0][0][1].s = get_value_int("gcs_recv[0][0][1].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[0][1][0].s = get_value_int("gcs_recv[0][1][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[0][1][1].s = get_value_int("gcs_recv[0][1][1].s",entries1,plot_par,grid_par);

 (*grid_par).gcs_recv[1][0][0].s = get_value_int("gcs_recv[1][0][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[1][0][1].s = get_value_int("gcs_recv[1][0][1].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[1][1][0].s = get_value_int("gcs_recv[1][1][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[1][1][1].s = get_value_int("gcs_recv[1][1][1].s",entries1,plot_par,grid_par);

 (*grid_par).gcs_recv[2][0][0].s = get_value_int("gcs_recv[2][0][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[2][0][1].s = get_value_int("gcs_recv[2][0][1].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[2][1][0].s = get_value_int("gcs_recv[2][1][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[2][1][1].s = get_value_int("gcs_recv[2][1][1].s",entries1,plot_par,grid_par);

 (*grid_par).gcs_recv[3][0][0].s = get_value_int("gcs_recv[3][0][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[3][0][1].s = get_value_int("gcs_recv[3][0][1].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[3][1][0].s = get_value_int("gcs_recv[3][1][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[3][1][1].s = get_value_int("gcs_recv[3][1][1].s",entries1,plot_par,grid_par);

 (*grid_par).gcs_recv[4][0][0].s = get_value_int("gcs_recv[4][0][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[4][0][1].s = get_value_int("gcs_recv[4][0][1].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[4][1][0].s = get_value_int("gcs_recv[4][1][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[4][1][1].s = get_value_int("gcs_recv[4][1][1].s",entries1,plot_par,grid_par);


 (*grid_par).gcs_recv[5][0][0].s = get_value_int("gcs_recv[5][0][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[5][0][1].s = get_value_int("gcs_recv[5][0][1].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[5][1][0].s = get_value_int("gcs_recv[5][1][0].s",entries1,plot_par,grid_par);
 (*grid_par).gcs_recv[5][1][1].s = get_value_int("gcs_recv[5][1][1].s",entries1,plot_par,grid_par);


 (*grid_par).nx[0][0]  = get_value_double("nx[0][0]",entries1,plot_par,grid_par);
 (*grid_par).ny[0][0]  = get_value_double("ny[0][0]",entries1,plot_par,grid_par);
 (*grid_par).nx[0][1]  = get_value_double("nx[0][1]",entries1,plot_par,grid_par);
 (*grid_par).ny[0][1]  = get_value_double("ny[0][1]",entries1,plot_par,grid_par);
 (*grid_par).nx[1][0]  = get_value_double("nx[1][0]",entries1,plot_par,grid_par);
 (*grid_par).ny[1][0]  = get_value_double("ny[1][0]",entries1,plot_par,grid_par);
 (*grid_par).nx[1][1]  = get_value_double("nx[1][1]",entries1,plot_par,grid_par);
 (*grid_par).ny[1][1]  = get_value_double("ny[1][1]",entries1,plot_par,grid_par);





}



  /* Ploting parameters */

void   get_plot_data_2d(struct entries *entries1, 
						struct PLOT_PAR *plot_par, 
						struct GRID_PAR *grid_par){


//#ifdef FILE_INPUT
	//char file_name[30];
////	FILE *file_data_ptr = (*plot_par).input_data_file_ptr;

	//strcpy(file_name, get_value_char("file_name",entries1,plot_par,grid_par));
	///* strcpy((*plot_par).input_file_name, get_value_char("file_name",entries1,plot_par,grid_par)); */
	//strcpy((*plot_par).output_file_name,file_name);
	//strcpy((*plot_par).input_file_name,"input_data_");
	//strcat((*plot_par).input_file_name, file_name  /* strcat((*plot_par).input_file_name,"input_data_"); */ );
		//(*plot_par).input_data_file_ptr = fopen((*plot_par).input_file_name,"w");

////		file_data_ptr = (*plot_par).input_data_file_ptr;
//#endif



	(*plot_par).time_level = get_value_int_print("time_level",entries1,plot_par,grid_par);
	// (*plot_par).prev_time_level = get_value_int_print("prev_time_level",entries1,plot_par,grid_par);
	(*plot_par).time_stamp = get_value_int_print("time_stamp",entries1,plot_par,grid_par);
	(*plot_par).prev_time_stamp = get_value_int_print("prev_time_stamp",entries1,plot_par,grid_par);

	(*plot_par).factor_1 = get_value_int_print("factor_1",entries1,plot_par,grid_par);
	(*plot_par).factor_2 = get_value_int_print("factor_2",entries1,plot_par,grid_par);



#ifdef SV
	strcpy((*plot_par).JSERHOST_env, "JSERHOST=");
	strcat((*plot_par).JSERHOST_env, get_value_char("host_name",entries1,plot_par,grid_par));
	putenv((*plot_par).JSERHOST_env);
#endif
/*  printf("<li> <code>JSERHOST enviroment var. = \"%s\"</code>%c</br>",(*plot_par).JSERHOST_env,10); */

}
